package com.javasm.springmybatis.controller;

import com.javasm.springmybatis.mail.EmailService;
import io.netty.util.internal.ThrowableUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @Author：xieyunfan
 * @Version：1.0
 * @Date：2021/12/29-22:27
 * @Since:jdk1.8
 * @Description:
 */
@RestController
public class EmailController {

    @Autowired
    private JavaMailSender javaMailSender;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private EmailService emailService;

    @RequestMapping("getEmailCode")
    public String getEmailCode(String email)
    {
        for (int i = 0; i < 100; i++) {
            emailService.sendEmail();
        }
        //无非就是存一份到redis
//        stringRedisTemplate.opsForValue().set("redis-key"+email,code,30,TimeUnit.SECONDS);
        System.out.println("厉害");
        return "success";

    }
}
